package com.hgh.util;

import com.hgh.model.EnemyTank;
import com.hgh.model.Missile;
import com.misakubex.BTFrame;

import java.util.concurrent.TimeUnit;

/**
 * 管理敌机发射子弹的线程
 * @author Administrator
 */
public class EnemyTankLocal implements Runnable {
    private EnemyTank enemyTank;

    public EnemyTankLocal(EnemyTank enemyTank){
        this.enemyTank =enemyTank;
    }

    @Override
    public void run() {
        while(true){
            if(!EnemyTank.isAlive(enemyTank)){
                break;
            }
            Missile missile =enemyTank.emissionMissile();
            if(missile!=null){
                BTFrame.threadPoolExecutor.execute(missile);
                BTFrame.addMissile(missile);
            }
            try {
                TimeUnit.MILLISECONDS.sleep(800);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
